<template>
  <div class="order_detail gray">
    <!-- 头部 -->
    <div class="header">
      <span class="iconfont back_icon" @click="back">&#xe616;</span>
      <h3>订单详情</h3>
    </div>
    <div class="goods_area">
      <!-- 商品列表 -->
      <div class="goods_list">
        <h3 class="goods_title">商品列表</h3>
        <div class="goods_box" v-for="(item, index) in orderDetail" :key="index">
          <img :src="item.goods_imgs[0]" class="goods_img">
          <div class="goods_info">
            <div class="goods_name">{{ item.goods_name }}</div>
            <div class="count">x{{ item.count }}</div>
          </div>
          <div class="goods_price">
            <span class="old_price">{{ item.goods_oldprice | priceFilter }}</span>
            <span class="current">￥{{ item.goods_price }}</span>
          </div>
        </div>
      </div>
      <!-- 商品总价 -->
      <div class="price_box">
        <span class="left">商品总价</span>
        <span class="right">￥{{ currentOrder.order_price }}</span>
      </div>
    </div>
    <!-- 订单信息 -->
    <div class="order_area">
      <div class="order_item">订单编号：{{ currentOrder.order_number }}</div>
      <div class="order_item">下单时间：{{ currentOrder.create_time }}</div>
      <div class="order_item">收货人：{{ currentOrder.username }}</div>
      <div class="order_item">收货地址：{{ currentOrder.consignee_addr }}</div>
      <div class="order_item">联系电话：{{ currentOrder.user_tel }}</div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'OrderDetail',
  data () {
    return {}
  },
  computed: {
    ...mapState(['orderDetail', 'currentOrder'])
  },
  filters: {
    priceFilter (value) {
      if (value !== 0) return '¥' + value
      return ''
    }
  },
  methods: {
    // 返回上一页
    back () {
      this.$router.push('/manageorder')
    }
  }
}
</script>

<style lang="less" scoped>
.order_detail {
  overflow: hidden;
  width: 15rem;
  height: 100%;
  overflow-y: scroll;
    &::-webkit-scrollbar {
      display: none;
    }
}
// 头部
.header {
  position: relative;
  width: 100%;
  height: 1.6rem;
  line-height: 1.6rem;
  font-size: .72rem;
  text-align: center;
  background: #fff;
  .back_icon {
    position: absolute;
    left: .4rem;
    font-size: .8rem;
    top: 50%;
    transform: translateY(-50%);
  }
}
// 商品列表
.goods_area {
  padding: .4rem;
  background: #fff;
  margin: .4rem;
  margin-bottom: 0;
  border-radius: .2rem;
}
.goods_list {
  border-bottom: 1px solid #eee;
  .goods_title {
    font-size: .64rem;
    font-weight: 600;
    text-align: center;
    padding-bottom: .4rem;
    border-bottom: 1px solid #eee;
  }
  // 每一项商品
  .goods_box {
    display: flex;
    height: 3.2rem;
    padding: .2rem 0;
    .goods_img {
      align-self: center;
      width: 2rem;
      height: 2rem;
      margin-right: .4rem;
      img {
        width: 100%;
      }
    }
    .goods_info {
      flex: 1;
      margin: 0 .4rem;
      .goods_name {
        font-size: .56rem;
      }
      .count {
        font-size: .48rem;
        color: #999;
        margin-top: .4rem;
      }
    }
    .goods_price {
      // width: 3rem;
      text-align: right;
      .old_price {
        font-size: .56rem;
        text-decoration: line-through;
        color: #999;
        margin-right: .2rem;
      }
      .current {
        font-size: .56rem;
      }
    }
  }
}
// 商品总价
.price_box {
  height: 1rem;
  line-height: 1rem;
  margin-top: .4rem;
  font-size: .64rem;
  .left {
    float: left;
    font-weight: 600;
  }
  .right {
    float: right;
    font-weight: 600;
  }
}
// 订单信息
.order_area {
  font-size: .64rem;
  padding: .4rem;
  margin: .4rem;
  border-radius: .2rem;
  background: #fff;
}
.order_item {
  color: #999;
  margin-bottom: .4rem;
}
.order_item:last-child {
  margin-bottom: 0;
}
</style>
